package com.example.springmavcase;

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.security.auth.message.MessageInfo;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2023-10-28
 * Time:14:29
 * Text：
 */
@RestController
@RequestMapping("/message")
public class messageWall {

    private List<message> messageInfos=new ArrayList<>();

    @RequestMapping("/said")
    public Boolean Said(message messageInfo){
        if(!StringUtils.hasLength(messageInfo.getTo()) || !StringUtils.hasLength(messageInfo.getFrom())
        || !StringUtils.hasLength(messageInfo.getSay())){
            return false;
        }
        else{
            messageInfos.add(messageInfo);
        }
        return true;
    }

    @RequestMapping("/getMessageInfo")
    public List<message> getMessageInfo(){

        return  messageInfos;
    }



}
